//
// File: socket.h
// Description: 
//

#ifndef SOCKET_H
#define SOCKET_H

#include <windows.h>
#include <winsock2.h>
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

#define BACKLOG 10

class Socket {
protected:
	SOCKET s;
	SOCKADDR_IN address;
	Socket() {};
public:
	Socket(SOCKET s, SOCKADDR_IN address);
	~Socket();
	void send(const void *prt, int size);
	int recv(const void *ptr, int size);

	void sendString(string str);

	void close();
	string toString();


	static bool winsockStarted;
	static bool startWinsock();
	static void closeWinsock();
};


class ServerSocket : public Socket {
private:
	int port;
	int backlog;
public:
	ServerSocket(int port);
	Socket *accept();
};

class ClientSocket : public Socket {
public: 
	ClientSocket(string & host, int port);
};


#endif
